#include <LengthUnit.h>
#include <iostream>
#include <sstream>

#define MILETOFEET  (1760 * 3)
#define YARDTOFEET  (3)
#define FEETTOFEET  (1)
using namespace std;

const UNIT_TYPE Length_type;

LengthUnit::LengthUnit(const int factorOfBaseUnit): Unit(Length_type,factorOfBaseUnit)
{
    
}


const Unit& LengthUnit::getBaseUnit() const
{  
  return Feet();
}

const string LengthUnit::getUnitString() const
{
    switch (factorOfBaseUnit)
    {
        case MILETOFEET:	    
            return "Mile";            
      
        case YARDTOFEET:	    
            return "Yard"; 

        case FEETTOFEET:
	    return "Feet"; 

        default:	    
            return "Invalid";
     }	
}
string LengthUnit::printEveryUnit(const PrintFormat& format, int amountLeftInBaseUnit) const
{
   ostringstream os;
   if (format == Format_Big)
   {
       LengthUnit(MILETOFEET).printOneUnit(os, amountLeftInBaseUnit);
       LengthUnit(YARDTOFEET).printOneUnit(os, amountLeftInBaseUnit);
       LengthUnit(FEETTOFEET).printOneUnit(os, amountLeftInBaseUnit);   
   }
   else   
   {
       LengthUnit(FEETTOFEET).printOneUnit(os, amountLeftInBaseUnit);
   }
   return os.str();
}       
   
   


const LengthUnit& LengthUnit::Mile()
{
  static LengthUnit unit(MILETOFEET);
  return unit;
}

const LengthUnit& LengthUnit::Yard()
{
  static LengthUnit unit(YARDTOFEET);
  return unit;
}

const LengthUnit& LengthUnit::Feet()
{
  static LengthUnit unit(FEETTOFEET);
  return unit;
}

